package com.firebird.app.reader.pdf.activity

import android.content.Intent
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.DividerItemDecoration
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.View
import com.firebird.app.reader.pdf.adapter.ChooseFileAdapter
import com.firebird.app.reader.pdf.bean.FileListBean
import com.firebird.app.reader.R
import java.util.*

class ChooseFileListActivity : AppCompatActivity() {
    private var fileList: RecyclerView? = null
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_choose_file_list)

        fileList = findViewById<View>(R.id.acfl_rv) as RecyclerView
        val layoutManager = LinearLayoutManager(this)
        layoutManager.orientation = LinearLayoutManager.VERTICAL
        fileList!!.addItemDecoration(DividerItemDecoration(
                this, DividerItemDecoration.VERTICAL))
        fileList!!.layoutManager = layoutManager
       initData()
    }

    private fun initData() {
        var fileName="新和建設Ａモデル"
        var updateTime="最終更新日時：2019年 3月 30日 11時59分"
       // val fileListBean1 : FileListBean = FileListBean(fileName,updateTime)
        val fileListBean1  = FileListBean(fileName,updateTime)
        fileName="新和建設Bモデル"
        updateTime="最終更新日時：2019年 3月 30日 11時59分"
        val fileListBean2  = FileListBean(fileName,updateTime)
        val fileListBeans: MutableList<FileListBean> = ArrayList<FileListBean>()
        fileListBeans.add(fileListBean1)
        fileListBeans.add(fileListBean2)
        val chooseFileAdapter = ChooseFileAdapter(fileListBeans)
        fileList!!.adapter = chooseFileAdapter
        chooseFileAdapter.setOnItemClickListener(object : ChooseFileAdapter.OnItemClickListener {
            override fun onItemClick(view: View?, position: Int) {
                val intent = Intent(this@ChooseFileListActivity, MainActivity::class.java)
                startActivity(intent)
            }
        })
    }
}